Post Selector all generators

The Selector allows to post-filter based on generated values using the kubernetes common labelSelector format. In the example, the list generator generates a set of two application which then filter by the key value to only select the env with value staging:

Example: List generator + Post Selector

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: ApplicationSet
  3. metadata:
  4. name: guestbook
  5. spec:
  6. generators:
  7. - list:
  8. elements:
  9. - cluster: engineering-dev
  10. url: https://kubernetes.default.svc
  11. env: staging
  12. - cluster: engineering-prod
  13. url: https://kubernetes.default.svc
  14. env: prod
  15. selector:
  16. matchLabels:
  17. env: staging
  18. template:
  19. metadata:
  20. name: '{{cluster}}-guestbook'
  21. spec:
  22. project: default
  23. source:
  24. repoURL: https://github.com/argoproj-labs/applicationset.git
  25. targetRevision: HEAD
  26. path: examples/list-generator/guestbook/{{cluster}}
  27. destination:
  28. server: '{{url}}'
  29. namespace: guestbook

The List generator + Post Selector generates a single set of parameters:

  1. - cluster: engineering-dev
  2. url: https://kubernetes.default.svc
  3. env: staging

It is also possible to use matchExpressions for more powerful selectors.

  1. spec:
  2. generators:
  3. - clusters: {}
  4. selector:
  5. matchExpressions:
  6. - key: server
  7. operator: In
  8. values:
  9. - https://kubernetes.default.svc
  10. - https://some-other-cluster